from datetime import datetime

# 请在此输入您的代码

while True:
    y, m, d = map(int, input().split())
    if y == m == d == 0: break
    start = datetime(year=y, month=1, day=1)
    d = datetime(year=y, month=m, day=d)
    delta = d - start
    print(delta.days + 1)
